﻿using NearAop.Interfaces;
using System;

namespace NearAop
{
    /// <summary>
    /// 属性代理(GET,SET)
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class)]
    public sealed class AddProxyPropertyAttribute : Attribute
        , IAopProxyPropertyGet
        , IAopProxyPropertySet
    {
        /// <summary>
        /// 本地代理模式
        /// </summary>
        public AddProxyPropertyAttribute() { }

        /// <summary>
        /// 属性代理(GET,SET)
        /// </summary>
        /// <param name="proxyType">代理类型</param>
        public AddProxyPropertyAttribute(Type proxyType) => ProxyType = proxyType;

        public Type ProxyType { get; }

        /// <summary>
        ///是否在触发事件前做新旧值相等测试
        /// </summary>
        public bool IsTestEquals { get; set; } = true;
    }

    /// <summary>
    /// 属性代理(SET)
    /// </summary>

    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class)]
    public sealed class AddProxyPropertySetAttribute : Attribute, IAopProxyPropertySet
    {
        /// <summary>
        /// 本地代理模式
        /// </summary>
        public AddProxyPropertySetAttribute() { }

        /// <summary>
        /// 属性代理(SET)
        /// </summary>
        /// <param name="proxyType">代理类型</param>
        public AddProxyPropertySetAttribute(Type proxyType) => ProxyType = proxyType;

        public Type ProxyType { get; }

        /// <summary>
        ///是否在触发事件前做新旧值相等测试
        /// </summary>
        public bool IsTestEquals { get; set; } = true;
    }

    /// <summary>
    /// 属性代理(GET)
    /// </summary>

    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class)]
    public sealed class AddProxyPropertyGetAttribute : Attribute, IAopProxyPropertyGet
    {
        /// <summary>
        /// 本地代理模式
        /// </summary>
        public AddProxyPropertyGetAttribute() { }

        /// <summary>
        /// 属性代理(GET)
        /// </summary>
        /// <param name="proxyType">代理类型</param>
        public AddProxyPropertyGetAttribute(Type proxyType) => ProxyType = proxyType;

        public Type ProxyType { get; }
    }
}
